﻿#region
/*******************************************************************************
** File Name:		    PromotionSettingService.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using EWineShop.Service.Contracts;
using EWineShop.Service.Model;
using EWineShop.IBatisRepository;
using EWineShop.Respository;
using System.Data;
using EWineShop.Entity;

namespace EWineShop.Service
{
    public class PromotionSettingService : IPromotionSettingService
    {
		 IPromotionSetting promotionSetting = new PromotionSettingRepository();
		 
		 #region  Auto Generation
		 

	
		public IList<PromotionSettingModel> GetAll ()
		{
			IList<EPromotionSetting> entity = promotionSetting.GetAll();
			
			if (entity == null)
            {
                return null;
            }
            
            IList<PromotionSettingModel> list = new List<PromotionSettingModel>();

            foreach (var item in entity)
            {
                PromotionSettingModel model = ConvertEntityToModel(item);
                list.Add(model);
            }
            return list;   
			
		}
		
		private PromotionSettingModel ConvertEntityToModel(EPromotionSetting entity)
		{
			if (entity == null)
            {
                return null;
            }
			PromotionSettingModel model = new PromotionSettingModel();
                        model.PromotionSettingID = entity.PromotionSettingID;
                        model.Due = entity.Due;
                        model.PresentDue = entity.PresentDue;
                        model.ValidateFrom = entity.ValidateFrom;
                        model.ValidateTo = entity.ValidateTo;
                        model.IsUpdate = entity.IsUpdate;
                        return model;
		}
		
		private EPromotionSetting ConvertModelToEntity(PromotionSettingModel model)
		{
			if (model == null)
            {
                return null;
            }
			EPromotionSetting entity = new EPromotionSetting();
                        entity.PromotionSettingID = model.PromotionSettingID;
                        entity.Due = model.Due;
                        entity.PresentDue = model.PresentDue;
                        entity.ValidateFrom = model.ValidateFrom;
                        entity.ValidateTo = model.ValidateTo;
                        entity.IsUpdate = model.IsUpdate;
                        return entity;
		}
		
		
		
		#endregion
    }
}